<template>
    <div id="tab-control">
        <div v-for="(item,index) in title"
             :class="{active:currentIndex == index}"
             @click="currentIndex = index"
        >
            <span>{{item }}</span>
        </div>
    </div>
</template>

<script>
  export default {
    name: "TabControl",
    props: {
      title: {
        type: Array,
        default() {
          return []
        }
      }
    },
    data() {
      return {
        currentIndex: 0
      }
    }
  }
</script>

<style scoped>

    #tab-control {
        display: flex;
        text-align: center;
        height: 40px;
        line-height: 40px;
        font-size: 15px;
    }

    #tab-control div {
        flex: 1;
    }

    #tab-control div span {
        padding: 5px;
    }

    .active span {
        color: var(--Highlight-font);
        border-bottom: 3px solid var(--Highlight-active);
    }

</style>